package com.neu.his.department.listener;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.neu.his.department.entity.Department;
import com.neu.his.department.mapper.DepartmentMapper;

public class DepartmentListener extends AnalysisEventListener<Department>{
	 private List<Department> list = new ArrayList<>();
	 
	 private DepartmentMapper departmentMapper;	

	public DepartmentListener() {
		super();
	}

	public DepartmentListener(DepartmentMapper departmentMapper) {
		super();
		this.departmentMapper = departmentMapper;
	}

	@Override
	public void invoke(Department data, AnalysisContext context) {
		// 每读取一行调用	
		System.out.println(data);
		list.add(data);
		
	}
 
	@Override
	public void doAfterAllAnalysed(AnalysisContext context) {
		// 所有数据解析完的操作
		int value = departmentMapper.batchInsert(list);
		System.out.println(value);

	}

}
